<ion-header>

  <ion-navbar color="mainColor">
    <ion-segment *ngIf="!showSearchBar" [(ngModel)]="sourceType" color="light">
      <ion-segment-button value="xt" (ionSelect)="IninClassType('xt')">
        习题
      </ion-segment-button>
      <ion-segment-button value="zy" (ionSelect)="IninClassType('zy')">
        资源
      </ion-segment-button>
    </ion-segment>
  </ion-navbar>

</ion-header>


<ion-content padding>
  <div *ngIf="show==true">
    <ion-segment [(ngModel)]="classType" color="mainColor" >
      <ion-segment-button value="60001" (ionSelect)="changeClassType('60001')">
        课前
      </ion-segment-button>
      <ion-segment-button value="60002" (ionSelect)="changeClassType('60002')">
        课中
      </ion-segment-button>
      <ion-segment-button value="60003" (ionSelect)="changeClassType('60003')">
        课后
      </ion-segment-button>
    </ion-segment>
  </div>
  <ion-refresher (ionRefresh)="doRefresh($event)">
    <ion-refresher-content pullingIcon="arrow-dropdown" pullingText="下拉刷新" refreshingSpinner="circles" refreshingText="努力刷新数据中...">
    </ion-refresher-content>
  </ion-refresher>
  <ion-list style="padding-top: 10px " *ngIf="show==true" >
    <ul>
      <ion-item-sliding *ngFor="let item of sourceList;let i=index">
        <ion-item>
          <li (click)="ViewSource(item.source_path,item.source_name,item.sourceid,item.source_type,item.source_id,item.isCheck,i,item.start_answer,item.publish_time,item.answer_type)">
            <div [ngSwitch]="item.source_type">
              <div *ngIf="item.isCheck==0">
                <img *ngSwitchCase="10001" src="./assets/imgs/exe_radio.png" alt="">
                <img *ngSwitchCase="10002" src="./assets/imgs/exe_select.png" alt="">
                <img *ngSwitchCase="10004" src="./assets/imgs/exe_subject.png" alt="">
                <img *ngSwitchCase="10006" src="./assets/imgs/exe_brain.png" alt="">
                <img *ngSwitchCase="10009" src="./assets/imgs/exe_vote.png" alt="">
                <img *ngSwitchCase="10008" src="./assets/imgs/exe_judge.png" alt="">
              </div>
              <div *ngIf="item.isCheck==1">
                <img *ngSwitchCase="10001" class="gray" src="./assets/imgs/exe_radio.png" alt="">
                <img *ngSwitchCase="10002" class="gray" src="./assets/imgs/exe_select.png" alt="">
                <img *ngSwitchCase="10004" class="gray" src="./assets/imgs/exe_subject.png" alt="">
                <img *ngSwitchCase="10006" class="gray" src="./assets/imgs/exe_brain.png" alt="">
                <img *ngSwitchCase="10009" class="gray" src="./assets/imgs/exe_vote.png" alt="">
                <img *ngSwitchCase="10008" class="gray" src="./assets/imgs/exe_judge.png" alt="">
              </div>
              <img *ngSwitchCase="40002" src="./assets/imgs/src-case.jpg" alt="">
              <img *ngSwitchCase="40003" src="./assets/imgs/src-link.jpg" alt="">
              <img *ngSwitchCase="40005" src="./assets/imgs/src-lecture.jpg" alt="">
              <img *ngSwitchCase="40009" src="./assets/imgs/src-video.jpg" alt="">
              <img *ngSwitchCase="40010" src="./assets/imgs/src-image.jpg" alt="">
              <img *ngSwitchCase="40011" src="./assets/imgs/src-pdf.jpg" alt="">
            </div>
            <div style="white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;" >
              <p class="title">{{item.source_name|slice: 0:20}}
                <span *ngIf="item.source_name.length>20">...</span>
              </p>
              <p class="info">
                <span>发布时间：{{item.create_time}}</span>
                <span class="ex">{{item.score}}{{scoreTitle}}</span>
              </p>
              <p class="info" *ngIf="classType=='60003'">截止时间：{{item.deadline}}</p>
            </div>
            <div (click)="downLoadFile(item.isCheck,item.source_path,$event,item.sourceid,item.source_type,i,item.start_answer)">
              <!--<span>新</span>-->
              <!--isCheck:0-未下载（未查看） 1-已下载（下载成功） 2-下载中 3-刚刚下载失败 4-上一次下载失败-->
              <ion-icon name="md-arrow-down" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==0"></ion-icon>
              <!--有哪些资源可下载待检查 视频，讲义，pdf-->
              <ion-icon name="md-checkmark" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==1"></ion-icon>
              <ion-icon name="md-pause" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==2"></ion-icon>
              <ion-icon name="md-close" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==3"></ion-icon>
              <ion-icon name="md-help" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==4"></ion-icon>
            </div>
          </li>
        </ion-item>
        <ion-item-options>
          <button samll *ngIf="item.source_type!='40009'" (click)="pushResources(item.source_id,item.source_type,item.unit_id)">发送资源</button>
        </ion-item-options>
      </ion-item-sliding>
    </ul>
  </ion-list>
  <ion-list>
    <ul *ngIf="show==false">
      <ion-item-sliding *ngFor="let item of sourceList;let i=index">
        <ion-item>
          <li (click)="ViewSource(item.source_path,item.source_name,item.sourceid,item.source_type,item.source_id,item.isCheck,i,item.start_answer,item.publish_time,item.answer_type)">
            <div [ngSwitch]="item.exercise_type">
              <div *ngIf="item.isCheck==0">
                <img *ngSwitchCase="10001" src="./assets/imgs/exe_radio.png" alt="">
                <img *ngSwitchCase="10002" src="./assets/imgs/exe_select.png" alt="">
                <img *ngSwitchCase="10004" src="./assets/imgs/exe_subject.png" alt="">
                <img *ngSwitchCase="10006" src="./assets/imgs/exe_brain.png" alt="">
                <img *ngSwitchCase="10009" src="./assets/imgs/exe_vote.png" alt="">
                <img *ngSwitchCase="10008" src="./assets/imgs/exe_judge.png" alt="">
              </div>
              <div *ngIf="item.isCheck==1">
                <img *ngSwitchCase="10001" class="gray" src="./assets/imgs/exe_radio.png" alt="">
                <img *ngSwitchCase="10002" class="gray" src="./assets/imgs/exe_select.png" alt="">
                <img *ngSwitchCase="10004" class="gray" src="./assets/imgs/exe_subject.png" alt="">
                <img *ngSwitchCase="10006" class="gray" src="./assets/imgs/exe_brain.png" alt="">
                <img *ngSwitchCase="10009" class="gray" src="./assets/imgs/exe_vote.png" alt="">
                <img *ngSwitchCase="10008" class="gray" src="./assets/imgs/exe_judge.png" alt="">
              </div>
                <img *ngSwitchCase="10001" src="./assets/imgs/exe_radio.png" alt="">
                <img *ngSwitchCase="10002" src="./assets/imgs/exe_select.png" alt="">
                <img *ngSwitchCase="10004" src="./assets/imgs/exe_subject.png" alt="">
                <img *ngSwitchCase="10006" src="./assets/imgs/exe_brain.png" alt="">
                <img *ngSwitchCase="10009" src="./assets/imgs/exe_vote.png" alt="">
                <img *ngSwitchCase="10008" src="./assets/imgs/exe_judge.png" alt="">
              <!-- <img *ngSwitchCase="40002" src="./assets/imgs/src-case.jpg" alt="">
              <img *ngSwitchCase="40003" src="./assets/imgs/src-link.jpg" alt="">
              <img *ngSwitchCase="40005" src="./assets/imgs/src-lecture.jpg" alt="">
              <img *ngSwitchCase="40009" src="./assets/imgs/src-video.jpg" alt="">
              <img *ngSwitchCase="40010" src="./assets/imgs/src-image.jpg" alt="">
              <img *ngSwitchCase="40011" src="./assets/imgs/src-pdf.jpg" alt=""> -->
            </div>
            <div style="white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;">
              <p class="title">{{item.source_name|slice: 0:20}}
                <span *ngIf="item.source_name.length>20">...</span>
              </p>
              <p class="info">
                <span>发布时间：{{item.create_time}}</span>
                <span class="ex">{{item.score}}{{scoreTitle}}</span>
              </p>
              <p class="info" *ngIf="classType=='60003'">截止时间：{{item.deadline}}</p>
            </div>
            <div (click)="downLoadFile(item.isCheck,item.source_path,$event,item.sourceid,item.source_type,i,item.start_answer)">
              <!--<span>新</span>-->
              <!--isCheck:0-未下载（未查看） 1-已下载（下载成功） 2-下载中 3-刚刚下载失败 4-上一次下载失败-->
              <ion-icon name="md-arrow-down" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==0"></ion-icon>
              <!--有哪些资源可下载待检查 视频，讲义，pdf-->
              <ion-icon name="md-checkmark" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==1"></ion-icon>
              <ion-icon name="md-pause" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==2"></ion-icon>
              <ion-icon name="md-close" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==3"></ion-icon>
              <ion-icon name="md-help" *ngIf="(item.source_type==='40005'||item.source_type==='40009'||item.source_type==='40011')&&item.isCheck==4"></ion-icon>
            </div>
          </li>
        </ion-item>
        <ion-item-options>
          <button (click)="sTheAnswer(item.teacher_id,item.unit_id,item.course_class_id,item.source_id,item.source_type,item.start_answer)" *ngIf="item.start_answer!==1" >开始答题</button>
          <button (click)="sTheAnswer(item.teacher_id,item.unit_id,item.course_class_id,item.source_id,item.source_type,item.start_answer)" *ngIf="item.start_answer==1" >结束答题</button>
          <button>统计</button>
        </ion-item-options>
      </ion-item-sliding>
    </ul>
  </ion-list>

</ion-content>
<ion-footer>
  <page-control [classcourseId]=classCourseId [unitId]=unitId></page-control>
</ion-footer>
